<template>
	<div>

		<el-tabs v-model="activeName" :stretch="flag" type="border-card" @tab-click="handleClick">
			<el-tab-pane label="用户列表" name="first">
				<div Style="margin: 0 auto; width: 70%; height: 750px;">
					<userInfo></userInfo>
				</div>
			</el-tab-pane>
			<el-tab-pane label="信息总览" name="four" icon="el-icon-search">
				<div Style="margin: 0 auto; width: 70%; height: 750px;"><userbrowse :mathe="mathe" :mathe1="mathe1" :mathe2="mathe2"></userbrowse></div>
			</el-tab-pane>

		</el-tabs>
	</div>
</template>

<script>
	import userInfo from '@/components/user_info/user_info.vue'
	// import mealInfo from '@/components/meal_info/Meal_info.vue'
	import userbrowse from '@/components/fold_line/user_browse.vue'
	import {
		request
	} from "network/request.js"
	export default {
		name: 'User_main',
		data: function() {
			return {
				activeName: 'first',
				flag: true,
				mathe: 0, //用户活跃比例
				mathe1: 0, //用户会员比例
				mathe2: 0 //用户总人数
			}
		},
		methods: {
			handleClick(tab, event) {
				if (tab.name == 'four') {
					let a = 0;
					let b = 0;
					let c = 0;
					request({
						url: '/User/UserStageLenth',
						method: 'get',
						params: {
							stage: "0"
						}
					}).then(res => {
						a = res.data.math1
						console.log(a)
						return request({
							url: '/User/UserStageLenth',
							method: 'get',
							params: {
								stage: "1"
							}
						})
					}).then(res=>{
						b = res.data.math1
						c=a+b
					this.mathe2=c
					this.mathe=Math.round((a/c)*100)
						return request({
							url: '/User/UserInfos',
							method: 'get'
						})
					}).then(res=>{
						
						 res.data=res.data.filter(item => item.umebnum>0)
						 this.mathe1=Math.round((res.data.length/c)*100)
						 
					})
				}
			}
		},
		components: {
			userInfo,
			userbrowse
		}
	}
</script>

<style>
</style>
